package algorithm.poj.p1000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;
import java.util.HashSet;
import java.util.Set;

public class P1775 {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P1775.class.getResource("P1775.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		Set<Integer> set = von();
		String line = stdin.readLine();
		while (true) {
			int n = Integer.valueOf(line.trim());
			if (n < 0) break;
			if (set.contains(n)) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
			line = stdin.readLine();
		}
	}
	
	private static int[] facs = new int[] {
		1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880
	};
	
	private static Set<Integer> von() {
		
		Set<Integer> set = new HashSet<Integer>();
		int[] c = new int[] {0};
		do {
			int n = 0;
			for (int i = 0; i < c.length; i ++) {
				n += facs[c[i]];
			}
			set.add(n);
			c = next_combination(c, 10);
		} while (c != null);
		return set;
	}
	
	public static int[] next_combination(int[] c, int M) {

		int index = c.length-1;
		for (; index > -1; index --) {
			if (c[index] < M-(c.length-index)) {
				c[index] ++;
				for (int i = index+1; i < c.length;i ++) {
					c[i] = c[index] + i - index;
				}
				break;
			}
		}
		if (index == -1) {
			if (c.length < M) {
				int[] nc = new int[c.length+1];
				for (int i = 0; i < nc.length; i ++) {
					nc[i] = i;
				}
				return nc;
			} else {
				return null;
			}
		} else {
			return c;
		}
	}
}